<template >

  <el-dialog title="登录" class="z"
             :visible.sync="dvisible" center width="400px">
  <el-form :model="user" >
    <el-form-item label="账号" :label-width="formLabelWidth">
      <el-input placeholder="请输入loginId" v-model.number="user.loginId" autocomplete="off" ></el-input>
    </el-form-item>
    <el-form-item label="密码" :label-width="formLabelWidth">
       <el-input placeholder="请输入密码" type="password" v-model="user.paw" autocomplete="off"></el-input>
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="Login">登录</el-button>
  </div>
</el-dialog>
   
</template>
<script>

import md5 from 'md5';
export default {
  // props:{
  //   dialogFormVisible:{
  //     type:Boolean,
  //     default:false
  //   }
  // },
    data() {
        return{
            user:{
                loginId:'',
                paw:''
            },
            formLabelWidth: '100px',
            count:""
            ,
             dvisible:true
        }
        
    },
    methods:{
       async Login(){
          if(this.user.loginId == "" || this.user.paw == ""){
                this.$message({
                      showClose: true,
                      message: '账号或密码不能为空',
                      type: 'error'
                });
                return;
          }
          
          const result = await this.$axios.post("/api/admin/login",{
             loginId :this.user.loginId,
              paw : md5(this.user.paw)  
          })
         
       if( result !==null && result.id){
         this.$message({
                      showClose: true,
                      message: '登录成功！',
                      type: 'success'
                });
          this.$router.push("/");

       }else{
         this.$message({
                      showClose: true,
                      message: '账号或密码错误！请再次核查！',
                      type: 'error'
                });
       }
        
        },
        logon(){
          store.commit("setLoginGui",false);
          // this.$router.push({name:"logon"});
        }
    },
    computed:{
      
     
    }
}
</script>
<style lang="less"  scoped>


</style>